package cn.javabb.common.exception;

import cn.javabb.common.enums.ResponseEnum;
import cn.javabb.common.exception.interfaces.ResultInterface;
import lombok.Getter;

/**
 * @desc:
 * @author: javabb (javabob(a)163.com)
 * @create: 2019/11/04 11:39
 */
@Getter
public class ResultException extends RuntimeException {
    private Integer code;

    /**
     * 统一异常处理
     * @param responseEnum 状态枚举
     */
    public ResultException(ResponseEnum responseEnum) {
        super(responseEnum.getMessage());
        this.code = responseEnum.getCode();
    }

    /**
     * 统一异常处理
     * @param responseEnum 枚举类型，需要实现结果枚举接口
     */
    public ResultException(ResultInterface responseEnum) {
        super(responseEnum.getMessage());
        this.code = responseEnum.getCode();
    }

    /**
     * 统一异常处理
     * @param code 状态码
     * @param message 提示信息
     */
    public ResultException(Integer code, String message) {
        super(message);
        this.code = code;
    }
}
